package com.patrol.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.patrol.dao.TaskPointDao;
import com.patrol.pojo.TaskPoint;
import com.patrol.pojo.User;
import com.patrol.service.TaskPointService;
import com.patrol.service.UserService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;


@Service
public class TaskPointServiceImpl extends ServiceImpl<TaskPointDao, TaskPoint> implements TaskPointService {

    @Resource
    private UserService userService;

    @Override
    public TaskPoint selectPointById(Integer taskId) {
        TaskPoint taskPoint = baseMapper.selectById(taskId);
        return taskPoint;
    }

    @Override
    public List<TaskPoint> selectAllPoint() {
        List<TaskPoint> list = baseMapper.selectList(null);
        return list;
    }

    @Override
    public boolean clockPoint(TaskPoint taskPoint) {
        TaskPoint point = baseMapper.selectById(taskPoint);
        if (null == point.getTaskInfo() && null == point.getTaskName()){
            return false;
        }
        point.setTaskStatement(1);
        int frequency = point.getFrequency();
        point.setFrequency(++frequency);
        baseMapper.updateById(point);
        return true;
    }
}
